package reco.db.validation;

import org.apache.commons.validator.UrlValidator;

public final class Constraints {
    /**
     * Avoids the construction of {@link Constraints} class instances.
     */
    private Constraints() {
        throw new UnsupportedOperationException("you should not try to create instances of this class");
    }

    public static final NotNullConstraintFactory notNull = new NotNullConstraintFactory();
    public static final NotBlankConstraintFactory notBlank = new NotBlankConstraintFactory();
    public static final CreditCardConstraintFactory creditCard = new CreditCardConstraintFactory();
    public static final EmailConstraintFactory email = new EmailConstraintFactory();
    public static final IpConstraintFactory ip = new IpConstraintFactory();
    public static final IsbnConstraintFactory isbn = new IsbnConstraintFactory();

    public static final MaxSizeConstraintFactory maxSize(int max) {
        return new MaxSizeConstraintFactory(max);
    }

    public static final MinSizeConstraintFactory minSize(int min) {
        return new MinSizeConstraintFactory(min);
    }

    public static final SizeConstraintFactory size(int min, int max) {
        return new SizeConstraintFactory(min, max);
    }

    public static final UrlConstraintFactory url = new UrlConstraintFactory();

    public static final UrlConstraintFactory url(int options) {
        return new UrlConstraintFactory(new UrlValidator(options));
    }

    public static final UrlConstraintFactory url(String... schemes) {
        return new UrlConstraintFactory(new UrlValidator(schemes));
    }

    public static final UrlConstraintFactory url(int options, String... schemes) {
        return new UrlConstraintFactory(new UrlValidator(schemes, options));
    }

    public static final <T extends Comparable<T>> BetweenConstraintFactory<T> between(T min, T max) {
        return new BetweenConstraintFactory<T>(min, max);
    }

    public static final <T> InConstraintFactory<T> in(T... values) {
        return new InConstraintFactory<T>(values);
    }

    public static final <T> NotInConstraintFactory<T> notIn(T... values) {
        return new NotInConstraintFactory<T>(values);
    }

    public static final <T extends Comparable<T>> MaxConstraintFactory<T> max(T max) {
        return new MaxConstraintFactory<T>(max);
    }

    public static final <T extends Comparable<T>> MinConstraintFactory<T> min(T min) {
        return new MinConstraintFactory<T>(min);
    }
}
